/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.netbeans.jobs1;

import cef.command.Command;
import cef.pui.EventConstructionException;
import coalescent.cef.command.RunBackwardRecursionCommand;
import coalescent.cef.command.listener.RunBackwardRecursionCommandListener;
import coalescent.cef.command.listener.exe.VisualizeRecursionCacheDistn;
import coalescent.cef.pui.RunBackwardRecursionEventImpl;
import coalescent.nb.jobs.properties.CoalescentComboPropertys;
import coalescent.nb.jobs.properties.CoalescentPropertys;
import commons.nb.jobs.CommonsJobPropertys;
import commons.nb.jobs.Job;
import commons.nb.jobs.properties.BuilderProperty;

/**
 * @author Susanta Tewari
 */
public class K69RunBackwardRecursionJob extends Job<RunBackwardRecursionEventImpl> {

    private BuilderProperty data_property;

    public K69RunBackwardRecursionJob() {

        setName("Infinite-Sites Model");
        setDisplayName("Infinite-Sites (K69)");
        setShortDescription("Infinite-Sites (K69)");


        // data
        data_property = CoalescentPropertys.K69Data_BUILDERS();

        addBuilderProperty(data_property);


        // recursion computations
        addComboProperty(CoalescentComboPropertys.FBasedGT_Recursion());
        addComboProperty(CoalescentComboPropertys.RECURSION_COMPUTATIONS());
        addJobProperty(
            CommonsJobPropertys.BOOLEAN_EXE_JOB_PROPERTY(
                new VisualizeRecursionCacheDistn(),
                CoalescentComboPropertys.RECURSION_PROFILE_CACHE_DISTN_PROP()));


        // attach listeners
        addCommandOutputListener(new RunBackwardRecursionCommandListener());
    }

    @Override
    public boolean isCancellable() {
        return RunBackwardRecursionCommand.isCancellable();
    }

    @Override
    protected RunBackwardRecursionEventImpl createEvent() throws EventConstructionException {

        data_property.getValue().setPropertyKeyPrefix("coalescent.builder.GeneTree");

        return new RunBackwardRecursionEventImpl(getProperties());
    }

    @Override
    public Class<RunBackwardRecursionEventImpl> getEventImplType() {
        return RunBackwardRecursionEventImpl.class;
    }

    @Override
    protected Command createCommand(RunBackwardRecursionEventImpl event) {
        return new RunBackwardRecursionCommand(event);
    }
}
